import { createSlice } from "@reduxjs/toolkit";
import type { RootState } from "./index";

interface CounterState {
  count: number;
}

const initialState: CounterState = {
  count: 0,
};

export const systemSlice = createSlice({
  name: "system",
  initialState,
  reducers: {
    add(state) {
      state.count += 1;
    },
    reduce(state) {
      state.count -= 1;
    },
  },
});

export const { add, reduce } = systemSlice.actions;

export const selectCount = (state: RootState) => state.system.count;

export default systemSlice.reducer;
